import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
const breadDataArr = [
  {path:'/',breadData:[]},

  {path:'/product',breadData:['PRODUCT CENTER','Surgical Stapler'.toUpperCase()]},
  {path:'/productdetails',breadData:['PRODUCT CENTER','Surgical Stapler'.toUpperCase()]},

  {path:'/news',breadData:['NEWS & EVENT']},
  {path:'/marketingactivities',breadData:['NEWS & EVENT','MARKETING ACTIVITIES']},
  {path:'/videocenter',breadData:['NEWS & EVENT',"VIDEO CENTER"]},
  {path:'/majorprojects',breadData:['NEWS & EVENT',"MAJOR PROJECT"]},

  {path:'/about',breadData:['ABOUT US']},
  {path:'/aboutteam',breadData:['ABOUT US','LEADERSHIP TEAM']},

  {path:'/esm',breadData:['ESM PROFESSIONALS']},
  {path:'/jiaoyun',breadData:['ESM PROFESSIONALS','CLINICAL EDUCATION']},
  {path:'/zhinang',breadData:['ESM PROFESSIONALS','SCIENTIFIC ADVISORY BOARD']},
  {path:'/terms',breadData:['TERMS OF USE']},
  {path:'/privacy',breadData:['Privacy Policy  ']},
  {path:'/cookie',breadData:['Cookie Statement']},
]
export default new Vuex.Store({
  state: {
    activeIndex:'/',
    breadData:[]
  },
  mutations: {
    changeActiveIndex(state,payload){
      let {key,path} = payload
      state.activeIndex = key+''
      window.scroll(0, 0)
    },
    getBreadData(state,payload){
      let breadData = breadDataArr.filter(item=>item.path === payload)
      if(breadData && breadData[0]) state.breadData = breadData[0].breadData
    }
  },
  actions: {
  },
  modules: { 
  }
})